home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 January: Mac OS SDK / Dev.CD Jan 96 SDK / Dev.CD Jan 96 SDK1.toast / Development Kits (Disc 1) / AppleScript / Development Tools / Interfaces / AppleScript 1.0 Interfaces / PInterfaces / Components.p < prev    next >
Encoding:
Text File  |  1993-04-08  |  8.2 KB  |  247 lines  |  [TEXT/MPS ]

  1. Created: Wednesday, January 27, 1992 at 5:31 PM
  2.  Components.p
  3.  Pascal Interface to the Macintosh Libraries
  4.  
  5.  Copyright Apple Computer, Inc. 1991, 1992
  6.  All rights reserved
  7. }
  8.  
  9.  
  10. {$IFC UNDEFINED UsingIncludes}
  11. {$SETC UsingIncludes := 0}
  12. {$ENDC}
  13.  
  14. {$IFC NOT UsingIncludes}
  15.  UNIT Components;
  16.  INTERFACE
  17. {$ENDC}
  18.  
  19. {$IFC UNDEFINED UsingComponents}
  20. {$SETC UsingComponents := 1}
  21.  
  22. {$I+}
  23. {$SETC ComponentsIncludes := UsingIncludes}
  24. {$SETC UsingIncludes := 1}
  25. {$IFC UNDEFINED UsingTypes}
  26. {$I $$Shell(PInterfaces)Types.p}
  27. {$ENDC}
  28. {$IFC UNDEFINED UsingTypes}
  29. {$I $$Shell(PInterfaces)Memory.p}
  30. {$ENDC}
  31. {$SETC UsingIncludes := ComponentsIncludes}
  32.  
  33. CONST
  34. gestaltComponentMgr = 'cpnt';
  35.  
  36. kAnyComponentType =            0;
  37. kAnyComponentSubType =         0;
  38. kAnyComponentManufacturer =    0;
  39. kAnyComponentFlagsMask =    0;
  40.  
  41. cmpWantsRegisterMessage = $80000000;
  42.  
  43.  
  44. TYPE
  45. ComponentDescription = RECORD
  46.  componentType: OSType;                                { A unique 4-byte code indentifying the command set }
  47.  componentSubType: OSType;                            { Particular flavor of this instance }
  48.  componentManufacturer: OSType;                        { Vendor indentification }
  49.  componentFlags: LONGINT;                            { 8 each for Component,Type,SubType,Manuf/revision }
  50.  componentFlagsMask: LONGINT;                        { Mask for specifying which flags to consider in search, zero during registration }
  51.  END;
  52.  
  53. ResourceSpec = RECORD
  54.  resType: OSType;                                    { 4-byte code  }
  55.  resId: INTEGER;                                    {    }
  56.  END;
  57.  
  58. ComponentResourcePtr = ^ComponentResource;
  59. ComponentResourceHandle = ^ComponentResourcePtr;
  60. ComponentResource = RECORD
  61.  cd: ComponentDescription;                            { Registration parameters }
  62.  component: ResourceSpec;                            { resource where Component code is found }
  63.  componentName: ResourceSpec;                        { name string resource }
  64.  componentInfo: ResourceSpec;                        { info string resource }
  65.  componentIcon: ResourceSpec;                        { icon resource }
  66.  END;
  67.  
  68. ComponentPtr = ^Component;
  69. Component = ^ComponentRecord;
  70. ComponentRecord = RECORD
  71.  data: ARRAY [0..0] OF LONGINT;
  72.  END;
  73.  
  74. ComponentInstance = ^ComponentInstanceRecord;
  75. ComponentInstanceRecord = RECORD
  76.  data: ARRAY [0..0] OF LONGINT;
  77.  END;
  78.  
  79. { Structure received by Component:  }
  80. ComponentParameters = PACKED RECORD
  81.  flags: CHAR;                                        { call modifiers: sync/async, deferred, immed, etc }
  82.  paramSize: CHAR;                                    { size in bytes of actual parameters passed to this call }
  83.  what: INTEGER;                                        { routine selector, negative for Component management calls }
  84.  params: ARRAY [0..0] OF LONGINT;                    { actual parameters for the indicated routine }
  85.  END;
  86.  
  87. ComponentResult = LONGINT;
  88.  
  89. ComponentRoutine = ProcPtr;
  90.  
  91. ComponentFunction = ProcPtr;
  92.  
  93.  
  94. {******************************************************
  95. * Required Component routines
  96. ******************************************************}
  97.  
  98. CONST
  99. kComponentOpenSelect = -1;                            { ComponentInstance for this open }
  100. kComponentCloseSelect = -2;                            { ComponentInstance for this close }
  101. kComponentCanDoSelect = -3;                            { selector # being queried }
  102. kComponentVersionSelect = -4;                        { no params }
  103. kComponentRegisterSelect = -5;                        { no params }
  104. kComponentTargetSelect = -6;                        { ComponentInstance for top of call chain }
  105.  
  106. { Set Default Component flags }
  107. defaultComponentIdentical = 0;
  108. defaultComponentAnyFlags = 1;
  109. defaultComponentAnyManufacturer = 2;
  110. defaultComponentAnySubType = 4;
  111. defaultComponentAnyFlagsAnyManufacturer = defaultComponentAnyFlags+defaultComponentAnyManufacturer;
  112. defaultComponentAnyFlagsAnyManufacturerAnySubType = defaultComponentAnyFlags+defaultComponentAnyManufacturer+defaultComponentAnySubType;
  113.  
  114. { errors from component manager & components }
  115. invalidComponentID = -3000;
  116. validInstancesExist = -3001;
  117. componentNotCaptured = -3002;
  118. componentDontRegister = -3003;
  119.  
  120. badComponentInstance = $80008001;
  121. badComponentSelector = $80008002;
  122.  
  123.  
  124. { *******************************************************
  125. *                                                     *
  126. *              APPLICATION LEVEL CALLS                *
  127. *                                                     *
  128. *******************************************************
  129. * Component Database Add, Delete, and Query Routines 
  130. *******************************************************
  131.  }
  132. FUNCTION RegisterComponent(cd: ComponentDescription;componentEntryPoint: ComponentRoutine;
  133.  global: INTEGER;componentName: Handle;componentInfo: Handle;componentIcon: Handle): Component;
  134.  INLINE $7001,$A82A;
  135. FUNCTION RegisterComponentResource(tr: ComponentResourceHandle;global: INTEGER): Component;
  136.  INLINE $7012,$A82A;
  137. FUNCTION UnregisterComponent(aComponent: Component): OSErr;
  138.  INLINE $7002,$A82A;
  139.  
  140. FUNCTION FindNextComponent(aComponent: Component;looking: ComponentDescription): Component;
  141.  INLINE $7004,$A82A;
  142. FUNCTION CountComponents(looking: ComponentDescription): LONGINT;
  143.  INLINE $7003,$A82A;
  144.  
  145. FUNCTION GetComponentInfo(aComponent: Component;VAR cd: ComponentDescription;
  146.  componentName: Handle;componentInfo: Handle;componentIcon: Handle): OSErr;
  147.  INLINE $7005,$A82A;
  148. FUNCTION GetComponentListModSeed: LONGINT;
  149.  INLINE $7006,$A82A;
  150.  
  151.  
  152. { *******************************************************
  153. * Component Instance Allocation and dispatch routines 
  154. *******************************************************
  155.  }
  156. FUNCTION OpenComponent(aComponent: Component): ComponentInstance;
  157.  INLINE $7007,$A82A;
  158. FUNCTION CloseComponent(aComponentInstance: ComponentInstance): OSErr;
  159.  INLINE $7008,$A82A;
  160.  
  161. FUNCTION GetComponentInstanceError(aComponentInstance: ComponentInstance): OSErr;
  162.  INLINE $700A,$A82A;
  163.  
  164.  
  165. {  direct calls to the Components  }
  166. FUNCTION ComponentFunctionImplemented(ci: ComponentInstance;ftnNumber: INTEGER): LONGINT;
  167.  INLINE $2F3C,$2,$FFFD,$7000,$A82A;
  168. FUNCTION GetComponentVersion(ci: ComponentInstance): LONGINT;
  169.  INLINE $2F3C,$0,$FFFC,$7000,$A82A;
  170. FUNCTION ComponentSetTarget(ci:ComponentInstance; target:ComponentInstance):LONGINT;
  171.  INLINE $2F3C,$4,$FFFA,$7000,$A82A;
  172.  
  173.  
  174. {****************************************************
  175. *                                                    *
  176. *               CALLS MADE BY Components             *
  177. *                                                    *
  178. ******************************************************}
  179.  
  180.  
  181. { *******************************************************
  182. * Component Management routines
  183. *******************************************************
  184.  }
  185. PROCEDURE SetComponentInstanceError(aComponentInstance: ComponentInstance;
  186.  theError: OSErr);
  187.  INLINE $700B,$A82A;
  188.  
  189. FUNCTION GetComponentRefcon(aComponent: Component): LONGINT;
  190.  INLINE $7010,$A82A;
  191. PROCEDURE SetComponentRefcon(aComponent: Component;theRefcon: LONGINT);
  192.  INLINE $7011,$A82A;
  193.  
  194. FUNCTION OpenComponentResFile(aComponent: Component): INTEGER;
  195.  INLINE $7015,$A82A;
  196. FUNCTION CloseComponentResFile(refnum: INTEGER): OSErr;
  197.  INLINE $7018,$A82A;
  198.  
  199.  
  200. { *******************************************************
  201. * Component Instance Management routines
  202. *******************************************************
  203.  }
  204. FUNCTION GetComponentInstanceStorage(aComponentInstance: ComponentInstance): Handle;
  205.  INLINE $700C,$A82A;
  206. PROCEDURE SetComponentInstanceStorage(aComponentInstance: ComponentInstance;
  207.  theStorage: Handle);
  208.  INLINE $700D,$A82A;
  209.  
  210. FUNCTION GetComponentInstanceA5(aComponentInstance: ComponentInstance): LONGINT;
  211.  INLINE $700E,$A82A;
  212. PROCEDURE SetComponentInstanceA5(aComponentInstance: ComponentInstance;
  213.  theA5: LONGINT);
  214.  INLINE $700F,$A82A;
  215.  
  216. FUNCTION CountComponentInstances(aComponent: Component): LONGINT;
  217.  INLINE $7013,$A82A;
  218.  
  219. {  useful helper routines for convenient method dispatching  }
  220. FUNCTION CallComponentFunction(params: ComponentParameters;func: ComponentFunction): LONGINT;
  221.  INLINE $70FF,$A82A;
  222. FUNCTION CallComponentFunctionWithStorage(storage: Handle;params: ComponentParameters;
  223.  func: ComponentFunction): LONGINT;
  224.  INLINE $70FF,$A82A;
  225. FUNCTION DelegateComponentCall(originalParams: ComponentParameters;
  226.  ci: ComponentInstance): LONGINT;
  227.  INLINE $7024,$A82A;
  228.  
  229. FUNCTION SetDefaultComponent(aComponent: Component;flags: INTEGER): OSErr;
  230.  INLINE $701E,$A82A;
  231. FUNCTION  OpenDefaultComponent(componentType: OSType; componentSubType: OSType ) : ComponentInstance;
  232.  INLINE $7021,$A82A;
  233. FUNCTION CaptureComponent(capturedComponent: Component;capturingComponent: Component): Component;
  234.  INLINE $701C,$A82A;
  235. FUNCTION UncaptureComponent(aComponent: Component): OSErr;
  236.  INLINE $701D,$A82A;
  237. FUNCTION RegisterComponentResourceFile(resRefNum:INTEGER;global:INTEGER):LONGINT;
  238.  INLINE $7014,$A82A;
  239.  
  240. {$ENDC} { UsingComponents }
  241.  
  242. {$IFC NOT UsingIncludes}
  243.  END.
  244. {$ENDC}
  245.  
  246.